package com.zh.note.huawei.onehundred.最少停车数;

/**
 * @Author: zhanghuan
 * @date: 2023/9/1 11:28
 * @description: create it
 */
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner s = new Scanner(System.in)) {
            String line = "1,1,0,0,1,1,1,0,1";
            solveMethod(line);
        }
    }

    private static void solveMethod(String line) {
        String cars = line.replace(",", "");

        int count = 0;

        int len = 0;
        for (char c : cars.toCharArray()) {
            if (c == '0') {
                if (len > 0) {
                    count += (len - 1) / 3 + 1;
                    len = 0;
                }
            } else {
                len++;
            }
        }
        if (len > 0) {
            count += (len - 1) / 3 + 1;
        }
        System.out.println(count);
    }
}

